﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace WPFSample.ControlXCVSample
{
    class ControlXCV : WPFSample.CutCopyAndPasteSample.CutCopyAndPaste
    {
        KeyGesture gestCut = new KeyGesture(Key.X, ModifierKeys.Control);
        KeyGesture gestCopy = new KeyGesture(Key.C, ModifierKeys.Control);
        KeyGesture gestPaste = new KeyGesture(Key.V, ModifierKeys.Control);
        KeyGesture gestDelete = new KeyGesture(Key.Delete);

        public ControlXCV()
        {
            this.Title = "Control X,C,and V";

            this.itemCut.InputGestureText = "Ctrl+X";
            this.itemCopy.InputGestureText = "Ctrl+C";
            this.itemPaste.InputGestureText = "Ctrl+V";
            this.itemDelete.InputGestureText = "Delete";
        }

        protected override void OnPreviewKeyDown(KeyEventArgs e)
        {
            base.OnPreviewKeyDown(e);
            e.Handled = true;

            if (this.gestCut.Matches(null, e))
            {
                this.CutOnClick(this, e);
            }
            else if (this.gestCopy.Matches(null, e))
            {
                this.CopyOnClick(this, e);
            }
            else if (this.gestPaste.Matches(null, e))
            {
                this.PasteOnClick(this, e);
            }
            else if (this.gestDelete.Matches(null, e))
            {
                this.DeleteOnClick(this, e);
            }
            else
            {
                e.Handled = false;
            }
        }
    }
}
